﻿@model WebVideo.EntityUser
<div class="user-wrapper">
    <div class="avatar">
        @{
            if (@Model.Avatar != null)
            {
                string v = "~/Content/Images/Avatar/" + @Model.Avatar;
            <img src="@Url.Content(v)" alt="" />
            }
            else
            {
                <img src="@Url.Content("../../Content/cssFrontEnd/images/avatar.jpg")" alt="" />
            }
            }

    </div>
    <div class="info">
        <h4>@Model.Name</h4>
        @{
            int? diem = @Model.PointVideo + @Model.PointFriend1 + @Model.PointFriend2;
            
        }
        <p class="info-point">@diem</p>
        <p class="info-friend">@ViewBag.SoBan</p>
        <p class="info-video">@ViewBag.SoVideo</p>
    
    </div>
    @{if (ViewBag.Friend == Request.Cookies["UserId"].Value)
      {
        <div class="think clearfix">
            <input type="text" name="think" id="think" placeholder="bạn đang nghĩ gì...?" onkeypress="return tableInputKeyPress(event)" />
        </div>
     }
    }
    <!--/ think-->
</div>
<!--/ user-wrapper-->

 @{ if (ViewBag.Friend != Request.Cookies["UserId"].Value)
    {
     if (ViewBag.Friended =="")
      {<div style="padding-bottom:10px; float:right;" ><a class="btn btn-small btn-warning" href="#" id ="@ViewBag.Friend" onclick ="return ThemFiend('@ViewBag.Friend.ToString()')">kết bạn <i class="icon-ok-sign icon-white"></i></a> </div>
    }
    else{
       <div style="padding-bottom:10px; float:right;" ><a class="btn btn-small btn-warning" href="#" >Bạn Bè <i class="icon-remove-sign icon-white"></i></a> </div>
   }
   }
 }
 <ul class="nav nav-list">
    @{
        if (ViewBag.Friend == Request.Cookies["UserId"].Value)
        {
            
            <li id="thongtin"><a href="@Url.Action("ThongTinCaNhan", "Individual", new { Friend = Model.UserName }, null)">Thông tin tài khoản</a></li>
            <li id="Wall"><a href="@Url.Action("Wall", "Individual", new { Friend = Model.UserName }, null)">Trang của tôi</a></li>
            <li id="WallFriend"><a href="@Url.Action("_WallFriend", "Individual")">Trang của bạn bè</a></li>
            <li id ="DanhSachBanBe"><a href="@Url.Action("DanhSachBanBe", "Individual", new { Friend = Model.UserName }, null)">Danh sách bạn bè</a></li>
            <li id ="AddFriend"><a href="@Url.Action("AddFriend", "Individual", new { Friend = Model.UserName }, null)">Mời thêm bạn</a></li>
            <li id ="ThongKe"><a href="@Url.Action("ThongKe", "Individual", new { Friend = Model.UserName }, null)">Thống kê</a></li>
            <li id ="VideoDaXem"><a href="@Url.Action("VideoDaXem", "Individual", new { Friend = Model.UserName }, null)">Video đã xem </a></li>
            <li id ="Payment"><a href="@Url.Action("Payment", "Individual", new { Friend = Model.UserName }, null)">Thanh toán </a></li>
            <li id="Chat"><a href="@Url.Action("Chat", "Individual")">Danh sách tin nhắn</a></li>
        }
        else
        {
             <li id="thongtin"><a href="@Url.Action("ThongTinCaNhan", "Individual", new { Friend = @ViewBag.Friend }, null)">Thông tin tài khoản</a></li>
            <li id="Wall"><a href="@Url.Action("Wall", "Individual", new { Friend =@ViewBag.Friend }, null)">Trang của tôi</a></li>@*
            <li id ="DanhSachBanBe" ><a href="@Url.Action("DanhSachBanBe", "Individual", new { Friend =@ViewBag.Friend }, null)">Danh sách bạn bè</a></li>*@
            <li id ="ThongKe"><a href="@Url.Action("ThongKe", "Individual", new { Friend = @ViewBag.Friend }, null)">Thống kê</a></li>
            <li id ="VideoDaXem"><a href="@Url.Action("VideoDaXem", "Individual", new { Friend = @ViewBag.Friend }, null)">Video đã xem </a></li>
         
        }
        <input id ="Their" type ="hidden"  value ="@Request.Cookies["UserId"].Value"/>
    }
    
</ul>

<script type="text/javascript">
    $(document).ready(function () {
        if (window.location.href.indexOf("ThongTinCaNhan") > -1) {
            $("#thongtin").addClass('active');
            return;
        }
        if (window.location.href.indexOf("_WallFriend") > -1) {
            $("#WallFriend").addClass('active');
            return;
        }
        if (window.location.href.indexOf("Wall") > -1) {
            $("#Wall").addClass('active');
            return;
        }
       
        if (window.location.href.indexOf("DanhSachBanBe") > -1) {
            $("#DanhSachBanBe").addClass('active');
            return;
        }
        if (window.location.href.indexOf("AddFriend") > -1) {
            $("#AddFriend").addClass('active');
            return;
        }
        if (window.location.href.indexOf("ThongKe") > -1) {
            $("#ThongKe").addClass('active');
            return;
        }
        if (window.location.href.indexOf("ThongKe") > -1) {
            $("#ThongKe").addClass('active');
            return;
        }
        if (window.location.href.indexOf("VideoDaXem") > -1) {
            $("#VideoDaXem").addClass('active');
            return;
        }
        if (window.location.href.indexOf("Payment") > -1) {
            $("#Payment").addClass('active');
            return;
        }
        if (window.location.href.indexOf("Chat") > -1) {
            $("#Chat").addClass('active');
            return;
        }
    });
</script>

<script type="text/javascript">
    function tableInputKeyPress(e) {
        e = e || window.event;
        var key = e.keyCode;

        if (key == 13) //Enter
        {
            var think = $('#think').val();
            var postURL = '@Url.Action("Think", "Individual")';
            var UserName = $('#Their').val();
            $.get(postURL, { "think": think, "UserName": UserName }, function (data) {
                if (data == "Complete") {
                    window.location.href = "@Url.Action("Wall", "Individual", new { Friend =  Request.Cookies["UserId"].Value})"
                }
                else {
                    alert("Error");
                }
            });

            }
    }

    function ThemFiend(UserName) {

        var getURL = '@Url.Action("KetBan", "Individual")';
         var c = confirm('Bạn chắc chắn muốn kết bạn với người này?');
         if (c) {
             $.get(getURL, { "UserName": UserName }, function (data) {
                 if (data != "Error") {
                     $("a#" + UserName + "").hide();
                     
                 }
                 else {
                     alert("Error");
                 }
             });
         }

         return true;
     };
</script>
